home *** CD-ROM | disk | FTP | other *** search
/ PC Users 8 / Cd Pc Users extra 8.iso / prog / inst / listx / setup.exe / CDRAW.CLS < prev    next >
Encoding:
Visual Basic class definition  |  1997-11-11  |  4.4 KB  |  154 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "CDraw"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = False
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Option Explicit
  11. Implements IMListPaint
  12. Implements IMCaptionPaint
  13.  
  14. '
  15. ' Pictures painted in various places, set by owndraw.drm
  16. '
  17. Public m_Picture1 As PictureBox
  18. Public m_Picture2 As PictureBox
  19. Public m_Picture3 As PictureBox
  20. Public m_Picture4 As PictureBox
  21.  
  22.  
  23.  
  24. Private Function IMCaptionPaint_CaptionHeight(Height As Integer) As Boolean
  25.    '
  26.    ' List/X+ control needs to know the caption height
  27.    '
  28.    m_Picture2.ScaleMode = Pixel
  29.    Height = m_Picture2.ScaleHeight + 3
  30.    '
  31.    ' Let the control know that the return value is valid
  32.    '
  33.    IMCaptionPaint_CaptionHeight = True
  34. End Function
  35.  
  36. Private Function IMCaptionPaint_PaintCaption(ByVal MPicture As MabryCtl.IMPicture) As Boolean
  37.    Dim h As Integer
  38.    Dim w As Integer
  39.    Dim x As Integer
  40.    Dim y As Integer
  41.    Dim s As String
  42.    
  43.    s = "List/X Rules"
  44.    
  45.    MPicture.ScaleMode = Pixel
  46.    MPicture.PaintPicture m_Picture2.Picture, 0, 0, 28, 28
  47.    
  48.    h = MPicture.TextHeight(s)
  49.    w = MPicture.TextWidth(s)
  50.    
  51.    x = 32
  52.    y = (MPicture.ScaleHeight - h) / 2
  53.    
  54.    MPicture.FontTransparent = True
  55.    MPicture.ForeColor = RGB(255, 255, 255)
  56.    MPicture.DrawText s, x - 1, y - 1, x + w - 1, y + h - 1, 0
  57.    MPicture.ForeColor = RGB(0, 0, 0)
  58.    MPicture.DrawText s, x + 1, y + 1, x + w + 1, y + h + 1, 0
  59.    MPicture.ForeColor = RGB(192, 192, 192)
  60.    MPicture.DrawText s, x, y, x + w, y + h, 0
  61.  
  62.    IMCaptionPaint_PaintCaption = True
  63. End Function
  64.  
  65. Private Function IMListPaint_ItemHeight(ByVal Item As Long, ItemHeight As Integer) As Boolean
  66.    If (Item >= 0) Then
  67.       '
  68.       ' List height
  69.       '
  70.       m_Picture1.ScaleMode = Pixel
  71.       ItemHeight = m_Picture1.ScaleHeight
  72.    Else
  73.       '
  74.       ' Heading height
  75.       '
  76.       m_Picture3.ScaleMode = Pixel
  77.       ItemHeight = m_Picture3.ScaleHeight
  78.    End If
  79.    IMListPaint_ItemHeight = True
  80. End Function
  81.  
  82. Private Function IMListPaint_PaintColumn(ByVal MPicture As MabryCtl.IMPicture, ByVal Item As Long, ByVal Column As Long, ByVal Selected As Boolean) As Boolean
  83.    Dim s As String
  84.    Dim h As Integer
  85.    Dim w As Integer
  86.    Dim x As Integer
  87.    Dim y As Integer
  88.        
  89.    MPicture.ScaleMode = Pixel
  90.    '
  91.    ' Handle headings here
  92.    '
  93.    If (Item = -1) Then
  94.       Select Case Column
  95.          Case 0:
  96.             IMListPaint_PaintColumn = True
  97.          Case 1:
  98.             s = "Text && Graphics!"
  99.    
  100.             MPicture.ScaleMode = Pixel
  101.    
  102.             h = MPicture.TextHeight(s)
  103.             w = MPicture.TextWidth(s)
  104.    
  105.             x = 0
  106.             y = (MPicture.ScaleHeight - h) / 2
  107.             MPicture.DrawText s, x, y, x + w, y + h, 0
  108.             
  109.             m_Picture4.ScaleMode = Pixel
  110.             MPicture.PaintPicture m_Picture4.Picture, MPicture.ScaleWidth - m_Picture4.ScaleWidth, 0, m_Picture4.ScaleWidth, m_Picture4.ScaleHeight
  111.             IMListPaint_PaintColumn = True
  112.          Case 2:
  113.             MPicture.PaintPicture m_Picture3.Picture, 0, 0, 20, 23
  114.             IMListPaint_PaintColumn = True
  115.          Case Else
  116.             IMListPaint_PaintColumn = False
  117.       End Select
  118.       Exit Function
  119.    End If
  120.    '
  121.    ' Painting the list itself
  122.    '
  123.    IMListPaint_PaintColumn = True
  124.    Select Case Column
  125.       Case 0:
  126.          '
  127.          ' stretchs to fit column
  128.          '
  129.          MPicture.PaintPicture m_Picture1.Picture, 0, 0
  130.          '
  131.          ' no stretch
  132.          '
  133. '         MPicture.PaintPicture Picture1.Picture, 0, 0, 32, 32
  134.       Case 1:
  135. '         s = MList1.List(Item)
  136.          MPicture.Font = m_Picture1.Font
  137.          If (Selected) Then
  138.             MPicture.ForeColor = RGB(255, 192, 0)
  139.          Else
  140.             MPicture.ForeColor = RGB(0, 192, 0)
  141.          End If
  142.          MPicture.DrawText "Cool!", 0, 0, MPicture.ScaleWidth, MPicture.ScaleHeight, tfSingleLine Or tfVertCenter Or tfCenter
  143.       Case 2:
  144.          MPicture.CurrentX = 0
  145.          MPicture.CurrentY = 0
  146.          MPicture.FillStyle = Item Mod 8
  147.          MPicture.FillColor = RGB(0, 0, 192)
  148.          MPicture.ForeColor = RGB(0, 0, 192)
  149.          MPicture.Line -Step(MPicture.ScaleWidth, MPicture.ScaleHeight), , BF
  150.       Case Else
  151.          IMListPaint_PaintColumn = False
  152.    End Select
  153. End Function
  154.